/**
 * 
 */
package com.example.radioclub.music;

import java.util.List;
import java.util.Map;

import javax.crypto.spec.PSource;

import com.example.radioclub.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @author wizard
 *
 */
public class SampleListActivity extends Activity implements OnItemClickListener{
	
	private class Adapter extends SimpleAdapter {
		private String[] array = {"Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel"};;
		private Context context;
		
		public Adapter(Context context) {
			super(context, null, 0, new String[]{}, new int[]{});
			// TODO Auto-generated constructor stub
			this.context = context;
		}
		
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			View view = LayoutInflater.from(this.context).inflate(R.layout.sample_layout, null);
			TextView text = (TextView) view.findViewById(R.id.sample_text);
			text.setText(this.array[position]);
			return view;
		}
		
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return this.array.length;
		}
		
		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return this.array[position];
		}		
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sample_list_layout);
		Adapter adapter = new Adapter(this);
		ListView view = (ListView) findViewById(R.id.sample_list);
		view.setAdapter(adapter);
		view.setFocusable(true);
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		// TODO Auto-generated method stub
		Toast.makeText(this, "Hello!", Toast.LENGTH_LONG).show();
		switch(view.getId()){
		case R.id.sample_text:
			Log.i("TAG", "Hello!");
			break;
		}
	}
}

